<template>
	<view class="mainBody">
		<view class="content">
			<view class="item-container">
				<view class="lineItem">
					<view class="leftStl">持卡人</view>
					<view class="rightStl">{{item.cardholderName}}</view>
				</view>
				<view class="lineItem">
					<view class="leftStl">是否为农行账户</view>
					<view class="rightStl">{{formate(item.abcBank)}}</view>
				</view>
				<view class="lineItem">
					<view class="leftStl">银行卡号</view>
					<view class="rightStl">{{item.cardId}}</view>
				</view>
				<view class="lineItem">
					<view class="leftStl">收款银行名称</view>
					<view class="rightStl">{{item.bankType}}</view>
				</view>
				<view class="lineItem">
					<view class="leftStl">支行信息</view>
					<view class="rightStl">{{item.bankInfo}}</view>
				</view>
			</view>

			<view class="tipMsg">
				<view>温馨提示：</view>
				<view>1.请一定正确填写开户行支行信息，已确保报销款项正常入账。</view>
				<view>2.示例：北京宋家庄支行</view>
			</view>
			<view class="bottomBtnView">
				<view class="btnLeft" @click="goBack()">返回修改</view>
				<view class="btnRight" @click="submitAccount()">确定</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		addBankCard,
		updateBankCard
	} from '@/api/reimburseApply.js'
	export default {
		data() {
			return {
				item: {},
				whetherBankMsg: false
			}
		},
		onLoad(option) {
			let item = JSON.parse(decodeURIComponent(option.item))
			// console.log('银行卡信息：', item);
			this.whetherBankMsg = item.whetherBankMsg
			this.item = {
				abcBank: item.abcBank,
				bankInfo: item.bankInfo,
				// bankPhone:item.bankPhone,
				bankType: item.bankType,
				cardId: item.cardId,
				cardholderName: item.cardholderName
			}
		},
		methods: {
			submitAccount() {
				if (this.whetherBankMsg) { //更新银行卡号
					updateBankCard(this.item).then(res => {
						// console.log('更新');
						if (res[1].respCode && res[1].respCode === 'FJKBP0000') {
							uni.navigateTo({
								url: "/pages/travelService/reimburse/reimburseAccountSuccess?bankMsg=" +
									encodeURIComponent(JSON.stringify(this.item)),
							});
						}
					})
				} else {
					// 提交用户的银行卡信息
					addBankCard(this.item).then(res => {
						// console.log('新增');
						if (res[1].respCode && res[1].respCode === 'FJKBP0000') {
							uni.navigateTo({
								url: "/pages/travelService/reimburse/reimburseAccountSuccess?bankMsg=" +
									encodeURIComponent(JSON.stringify(this.item)),
							});
						}
					})
				}
			},
			formate(val) {
				let arr = {
					0: '否',
					1: '是'
				}
				return val = arr[val]
			},
			// 返回修改
			goBack() {
				uni.navigateBack({
					delta: 1
				})
			}


		}
	}
</script>

<style lang="scss" scoped>
	.mainBody {
		background: #f7f7f7;
		min-height: 100%;
		color: #333333;
	}

	.content {
		min-height: 100%;
		padding-top: 20rpx;
	}

	.item-container {
		top: 20rpx;
		height: 352rpx;
		background-color: #fff;

		.lineItem {
			display: flex;
			justify-content: space-between;
			padding: 0 32rpx;
			font-size: 32rpx;
			font-weight: 400;
			color: #666666;
			line-height: 64rpx;
		}

		.lineItem:nth-child(1) {
			padding-top: 16rpx;
		}
	}

	.tipMsg {
		height: 160rpx;
		padding: 32rpx 32rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #666666;
		line-height: 45rpx;
		word-wrap: break-word;
		word-break: normal;
	}

	.bottomBtnView {
		display: flex;
		justify-content: space-between;
		bottom: 0;
		height: 154rpx;
		margin: 32rpx;

		.btnLeft {
			width: 328rpx;
			height: 88rpx;
			line-height: 88rpx;
			text-align: center;
			font-size: 36rpx;
			font-weight: 500;
			border: #FFA900 1rpx solid;
			color: #FFA900;
			border-radius: 8rpx;
			margin-right: 30rpx;
		}

		.btnRight {
			width: 328rpx;
			height: 88rpx;
			line-height: 88rpx;
			text-align: center;
			font-size: 36rpx;
			font-weight: 500;
			color: #FFFFFF;
			background: #FFA900;
			border-radius: 8rpx
		}
	}
</style>
